
#include "general.h"
#include "controlbar.h"
#include "globals.h"

BEGIN_EVENT_TABLE(CControlBar, wxWindow)
	EVT_SIZE(CControlBar::OnSize)
END_EVENT_TABLE()

CControlBar::CControlBar(
	wxWindow *parent, wxWindowID id, 
	const wxPoint &position, const wxSize& size, long style 
	)
	: wxWindow(parent, id, position, size, style)
{
	CreateChildren();
}

void CControlBar::CreateChildren()
{
	int id = 0;
	std::list<OperationCategory::Base*>::iterator iter;
	for (iter=g_operation_categories.begin(); iter!=g_operation_categories.end(); ++iter)
	{
		OperationCategory::Base* pBase = *iter;
		pBase->CreateWindow(this, ++id, wxDefaultPosition , wxDefaultSize, 0);
		pBase->Activate(false);
	}
	g_operation_categories.front()->Activate();

}

CControlBar::~CControlBar()
{
}

void CControlBar::OnSize(wxSizeEvent& event)
{

	int id = 0;
	std::list<OperationCategory::Base*>::iterator iter;
	for (iter=g_operation_categories.begin(); iter!=g_operation_categories.end(); ++iter)
	{
		OperationCategory::Base* pBase = *iter;
		pBase->MoveWindow(GetClientRect());
	}
}